<?php
 	//initial user id
	if (!isset($_SESSION['id'])){
		$_SESSION['id']=md5(rand());
	}
  	//initial end
	$id=$_SESSION['id'];
	import_request_variables('pg','v_');
	$csn=$v_csn;
	$ssn=$v_ssn;
	if (isset($v_dsn)){
		$dsn=$v_dsn;
	}
	if (isset($v_grp)){
		$grp = $v_grp;
		if ($csn == 8){
			$dbno = "1"; //Antibody products.
			foreach($grp as $val){
				$sql="select * from products where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn == 9){
			$dbno = "2"; //siRNA Lentivirus
			foreach($grp as $val){
				$sql="select * from prodsirna where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn == 10){
			$dbno = "3"; //Lentivirus
			foreach($grp as $val){
				$sql="select * from prodlenti where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn == 11){
			$dbno = "4";  //Adevnovirus
			foreach($grp as $val){
				$sql="select * from prodadenovirus where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn == 17){
			$dbno = "1"; // Tag Antibody
			foreach($grp as $val){
				$sql="select * from products where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn == 18){
			$dbno = "1"; //Loading Control
			foreach($grp as $val){
				$sql="select * from products where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn == 15){
			$dbno="13"; //Cell Immortalization
			foreach($grp as $val){
				$sql="select * from prodcellimmort where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn == 13){
			$dbno="6"; //Transfection Reagents
			foreach($grp as $val){
				$sql="select * from prodtrans where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn == 19){
			$dbno="8"; //Secondary Antibody
			foreach($grp as $val){
				$sql="select * from prodsecondanti where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn==29&&$val<>'G299'&&$val<>'TM001'&&$val<>'TM002'&&$val<>'TM003'&&$val<>'TM004'&&$val<>'TM050'&&$val<>'TM051'&&$val<>'TM999-100'&&$val<>'TM999-500'&&$val<>'G255'){
			$dbno="18"; //Immortalized Primary Cell
			foreach($grp as $val){
				$sql="select * from prodihc where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn==29&&($val=='TM001'||$val=='TM002'||$val=='TM003'||$val=='TM004'||$val=='TM050'||$val=='TM051'||$val=='G299'||$val=='TM999-100'||$val=='TM999-500'||$val=='G255')){
			$dbno="30"; // Stem cell culture
			foreach($grp as $val){
				$sql="select * from prod_cell_culture where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan = 1;
					$pname = addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn==43&&$val<>'G299'&&$val<>'TM001'&&$val<>'TM002'&&$val<>'TM003'&&$val<>'TM004'&&$val<>'TM050'&&$val<>'TM051'&&$val<>'TM999-100'&&$val<>'TM999-500'&&$val<>'G255'){
			$dbno="43"; //Primary Cell
			foreach($grp as $val){
				$sql="select * from prod_primary_cells where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn==43&&($val=='TM001'||$val=='TM002'||$val=='TM003'||$val=='TM004'||$val=='TM050'||$val=='TM051'||$val=='G299'||$val=='TM999-100'||$val=='TM999-500'||$val=='G255')){
			$dbno="30"; // Stem cell culture
			foreach($grp as $val){
				$sql="select * from prod_cell_culture where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn == 12){
			$dbno="5"; //PCR, RT-PCR, qPCR
			foreach($grp as $val){
				$sql="select * from prodpcr where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn == 14){
			$dbno="7";  //Viral Expression
			foreach($grp as $val){
				$sql="select * from prodviralexp where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn == 16 && $ssn == 3712){
			$dbno="7";  //RNA siRNA expression
			foreach($grp as $val){
				$sql="select * from prodviralexp where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn == 16 && $ssn == 3710){
			$dbno="9"; //Custom iLenti RNA
			foreach($grp as $val){
				$sql="select * from custom_service where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn == 20){
			$dbno="14"; //DNA Purification
			foreach($grp as $val){
				$sql="select * from proddnapure where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn == 25){
			$dbno="15";  //Custom Services
			foreach($grp as $val){
				$sql="select * from custom_service where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn == 44){
			$dbno="44"; // Protein Purification
			foreach($grp as $val){
				$sql="select * from prodproteinpure where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					
					
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
					
				}
			}
		}
		if ($csn == 45){
			$dbno="45"; // Protein Purification
			foreach($grp as $val){
				$sql="select * from prod_cell_lines where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					
					
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
					
				}
			}
		}
		if ($csn == 22 && $ssn == 3916){
			$dbno="45"; //Markers
			foreach($grp as $val){
				$sql="select * from prodmarkers where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					
					
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
					
				}
			}
		}
		if ($csn == 22 && $ssn == 3919){
			$dbno="16"; //Chemicals
			foreach($grp as $val){
				$sql="select * from prodbiochems where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					
					
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
					
				}
			}
		}
		if ($csn == 22 && $ssn == 3920){
			$dbno="17"; //Antibiotics
			foreach($grp as $val){
				$sql="select * from prodantibiotics where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					
					
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
					
				}
			}
		}
		if ($csn == 23 && $ssn <> 3908){
			$dbno="12"; //Cell Lysate
			foreach($grp as $val){
				$sql="select * from prodlysates where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					
					
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
					
				}
			}
		}
		if ($csn == 23 && $ssn == 3908){
			$dbno="1"; //Tag Antibody
			foreach($grp as $val){
				$sql="select * from products where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					
					
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
					
				}
			}
		}
		if ($csn == 21 && $ssn <> 11255){
			$dbno="11"; //Western Blot
			foreach($grp as $val){
				$sql="select * from prodwesternblot where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					
					
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn == 21 && $ssn == 11255){
			$dbno="10"; //DNA/Protein Markers
			foreach($grp as $val){
				$sql="select * from prodmarkers where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					
					
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
					
				}
			}
		}
		if ($csn == 26 && $ssn == 11838 && $dsn<>12288){
			$dbno="26"; //miRNA expression vectors
			foreach($grp as $val){
				$sql="select * from premade_mirna_exp where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['size'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$added=addslashes($r['productType']);
					$pname=addslashes($r['miRNAName']);
					$supplier=$r['supplier'];
					switch($dsn){
						case 12251: $addon="LentimiRa-";
						break;
						case 14442: $addon="LentimiRa-No GFP-";
						break;
						case 12252: $addon="Tet-LentimiRa-";
						break;
						case 12253: $addon="AdmiRa-";
						break;
						case 12254: $addon="LentimiRa-Off-";
						break;
						case 12255: $addon="AdmiRa-";
						break;
					}
					
					
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$addon$pname $added','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn == 26 && $ssn == 11838 && $dsn==12288){
			$dbno="27"; //3'UTR Lenti-reporter vector
			foreach($grp as $val){
				$sql="select * from mirna_validator where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan = 1;
					$pname = addslashes($r['pname']);
					$supplier=$r['supplier'];
					
					
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
					
				}
			}
		}
		if ($csn == 26 && $ssn == 11839 && $dsn==12256){
			$dbno="5";
			foreach($grp as $val){
				$sql="select * from prodpcr where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan = 1;
					$pname = addslashes($r['pname']);
					$supplier=$r['supplier'];
					
					
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
					
				}
			}
		}
		if ($csn == 26 && $ssn == 11839 && $dsn==12257){
			$dbno="19"; //miRNA cDNA Synthesis Kit 
			foreach($grp as $val){
				$sql="select * from prodcDNAmirna where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan = 1;
					$pname = addslashes($r['pname']);
					$supplier=$r['supplier'];
					
					
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
					
				}
			}
		}
		if ($csn == 26 && $ssn == 11839 && $dsn == 12258){
			$dbno="28"; //Individual miRNA Primer Sets
			foreach($grp as $val){
				$sql="select * from mirna_primers_sets where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['size'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$added=' Primer Set';
					$pname=addslashes($r['miRNAName']);
					$supplier=$r['supplier'];
					
					
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname$added','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
					
				}
			}
		}
		if ($csn == 26 && $ssn == 11840){
			$dbno="15"; //Custom Profiling
			foreach($grp as $val){
				$sql="select * from custom_service where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['size'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan=1;
					$pname=addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
		if ($csn == 30 && $ssn == 11346 && $dsn==11726){
			$dbno="30"; // Stem cell culture
			foreach($grp as $val){
				$sql="select * from prod_cell_culture where catNo like '$val'";
				$result=mysql_query($sql,$db);
				$rows=mysql_num_rows($result);
				if ($rows>0){
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan = 1;
					$pname = addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}elseif ($csn == 30){
			foreach($grp as $val){
				$sql="select * from prodstemcell where LOWER(catNo) like '$val'";
				$result=mysql_query($sql,$db);
				$row=mysql_num_rows($result);
				if ($row>0){
					$dbno="31"; //iPSC Lentivirus
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan = 1;
					$pname = addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
				$sql="select * from prodprotein where LOWER(catNo) like '$val'";
				$result=mysql_query($sql,$db);
				$row=mysql_num_rows($result);
				if ($row>0){
					$dbno="32"; //iPSC Recombinant Proteins
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan = 1;
					$pname = addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
				$sql="select * from prodipscplasmid where LOWER(catNo) like '$val'";
				$result=mysql_query($sql,$db);
				$row=mysql_num_rows($result);
				if ($row>0){
					$dbno="33"; //iPSC Plasmids
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan = 1;
					$pname = addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
				$sql="select * from prodsmallmolecule where LOWER(catNo) like '$val'";
				$result=mysql_query($sql,$db);
				$row=mysql_num_rows($result);
				if ($row>0){
					$dbno="34"; //iPSC Small Molecules
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan = 1;
					$pname = addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
				$sql="select * from prod_feeder_cell where LOWER(catNo) like '$val'";
				$result=mysql_query($sql,$db);
				$row=mysql_num_rows($result);
				if ($row>0){
					$dbno="35"; //iPSC Feeder Cells
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan = 1;
					$pname = addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
				$sql="select * from prod_growth_factor where LOWER(catNo) like '$val'";
				$result=mysql_query($sql,$db);
				$row=mysql_num_rows($result);
				if ($row>0){
					$dbno="36"; //iPSC Growth Factors
					$r = mysql_fetch_array($result);
					$catno=$val;
					$quan= $r['quantity'];
					$price=$r['price'];
					$pcat=$csn;
					$cart = $v_car;
					$orderquan = 1;
					$pname = addslashes($r['pname']);
					$supplier=$r['supplier'];
					//check if there is a same product ordered under same ID
					$chk="select * from shoplist where sessionid='$id' and catNo='$catno'";
					$chk_res=mysql_query($chk,$db);
					$chk_rw=mysql_num_rows($chk_res);
					if ($chk_rw>0){
						$upd="update shoplist set quantity = quantity + $orderquan where sessionid like '$id' and catNo like '$catno'";
						$insres=mysql_query($upd,$db);
					}else{
						$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
						$insres=mysql_query($ins,$db);
					}
				}
			}
		}
	}else{
		if (isset($v_expcart) && strtolower($v_expcart) == 'add to cart'){
			echo "<script language=javascript>alert('Before you click on add to cart button, please selet at least one product.');history.go(-1);</script>";
			exit;
		}else{
			$catno=$v_catno;
			$quan=$v_quan;
			$price=$v_price;
			$pcat=$v_pcat;
			$cart = $v_car;
			$orderquan=$v_orderquan;
			if ($v_pname){
				$pname=addslashes($v_pname);
			}
			if ($v_supplier){
				$supplier=$v_supplier;
			}
			switch ($pcat){
				case "8"://Antibodies
					$dbno="1";
					break;
				case "9"://Pre-Made siRNA
					$dbno="2";
					break;
				case "10"://Pre-Made Lentivirus 
					$dbno="3";
					break;
				case "11"://Pre-Made Adenovirus
					$dbno="4";
					break;
				case "12"://PCR/qPCR
					$dbno="5";
					break;
				case "13"://Transfection
					$dbno="6";
					break;
				case "14"://Viral Expression
					$dbno="7";
					break;
				case "19"://Secondary Antibodies
					$dbno="8";
					break;
				case "16":
					if ($ssn == "3710"){//siRNA
						$dbno="9";
					}elseif ($ssn == 3712){//Viral Expression
						$dbno = "7"; 
					}
					break;
				case "21":
					if ($ssn <> "11255"){//Western Blot
						$dbno="11";
					}elseif ($ssn == 11255){// DNA/Protein Marker
						$dbno="10"; 
					}
					break;
				case "23":
					if ($ssn <> "3908"){//Cell Lysates
						$dbno="12";
					}elseif ($ssn == "3908"){//Tag Antibody
						$dbno="1";
					}
					break;
				case "15"://Cell Immortalization
					$dbno="13";
					break;
				case "20"://DNA purification
					$dbno="14";
					break;
				case "25"://Custom Service
					$dbno="15";
					break;
				case "22":
					if ($ssn =="3919"){//Chemicals
						$dbno="16";
					}elseif ($ssn == 3920){//Antibiotics
						$dbno="17";
					}elseif ($ssn == 3916){//Markers
						$dbno="45";
					}
					break;
				case "29"://Immortalized Primary Cells
					if ($catno == "G299"){
						$dbno="30"; //Flasks in Cell Culture
					}
					else{
						$dbno="18"; //Primary Cells
					}
					break;
				case "26":
					if ($ssn == 11839 && $dsn == 12257){//miRNA DNA Synthesis Kit
						$dbno="19";		
					}
					if ($ssn == 11839 && dsn == 12258){//Individual miRNA Primers Sets
						$dbno="28";	
					}
					if ($ssn == 11839 && $dsn == 12256){//PCR, RT-PCR, qPCR
						$dbno="5";		
					}
					if ($ssn == 11838 && $dsn <> 12288){//miRNA Expression
						$dbno="26";	
					}
					if ($ssn == 11838 && $dsn == 12288){//miRNA 3'UTR Lenti-Reporter
						$dbno="27";	
					}
					if ($ssn == 11840 && $dsn == 12261){//Custom Profiling
						$dbno="15";	
					}
					break;
				case "30":
					if ($ssn == 11346 && $dsn == 11726){//Stem Cell Culture
						$dbno="30";		
					}
					$dbarray = array("prodstemcell","prodprotein","prodipscplasmid","prodsmallmolecule","prod_feeder_cell","prod_growth_factor");
					foreach ($dbarray as $dbtable){
						$sql="select * from $dbtable where catNo like '$catno'";
						$result=mysql_query($sql,$db);
						$row=mysql_num_rows($result);
						if ($row>0){
							if ($dbtable == "prodstemcell"){
								$dbno="31"; //iPSC Lentivirus
							}
							if ($dbtable == "prodprotein"){
								$dbno="32"; //iPSC Recombinant Proteins
							}
							if ($dbtable == "prodipscplasmid"){
								$dbno="33"; //iPSC Plasmids
							}
							if ($dbtable == "prodsmallmolecule"){
								$dbno="34"; //iPSC Small Molecules
							}
							if ($dbtable == "prod_feeder_cell"){
								$dbno="35"; //iPSC Feeder Cells
							}
							if ($dbtable == "prod_growth_factor"){
								$dbno="36"; //iPSC Growth Factors
							}
						}
					}
					break;
				case "17"://Tag Antibodies
					$dbno="1";
					break;
				case "18"://Loading Controls
					$dbno="1";
					break;
				case "43"://Primary Cells
					if ($catno == "G299"){
						$dbno="30"; //Flasks in Cell Culture
					}
					else{
						$dbno="43"; //Primary Cells
					}
					break;
				case "44"://Protein Purification
					$dbno="44";
					break;
				case "99"://other products
					$dbno="99";
					break;
				case "999"://other old products
					$dbno="999";
					break;
			}
			//$csn=$pcat;
			if (isset($catno) && isset($quan) && isset($price) && isset($orderquan)){
				//check if there is a same product ordered under same ID
				$chk="select * from shoplist where sessionid='$id' and catNo like '$catno'";
				$chk_res=mysql_query($chk,$db);
				$chk_rw=mysql_num_rows($chk_res);
				if ($chk_rw>0){
					$upd="update shoplist set quantity = quantity + $orderquan where sessionid='$id' and catNo like '$catno'";
					$insres=mysql_query($upd,$db);
				}else{
					$ins="insert into shoplist (catNo,dbNo,pname,sessionid,unit,price,quantity,supplier,promotioncode) values ('$catno','$dbno','$pname','$id','$quan','$price',$orderquan,'$supplier','')";
					$insres=mysql_query($ins,$db);
				}
			}else{
				echo "<script language=javascript>alert('No params.');</script>";
			}
		}
	}
?>
